package com.example.lotapp.network;

import android.text.TextUtils;

import com.example.lotapp.ApplicationData;
import com.example.lotapp.utils.MD5Encrypt;


public class ParamUtils {
	private static String mUuid = "3C075461B9B0";
	private static String mKey = "8888";
	
	
	public static void setUuid(String uuid) {
		if (!TextUtils.isEmpty(uuid)){
			mUuid = uuid;
		}
	}
	
	public static String getUuid() {
		return mUuid;
	}
	
	public static String getKey(){
		return mKey;
	}

	public static String getRequestSign(String uuid, String platformCode, String platformVersion, String appVersion,
			String params, String userId, String key) {
		String sign = uuid + platformCode + platformVersion + appVersion + params + userId + key;
		sign = MD5Encrypt.md5Encryption(sign);
		return sign;
	}

	public static String getRequestParam(String jsonParam, String action) {
		String uuid = getUuid();
		String platformCode = "Android";
		String platformVersion = android.os.Build.VERSION.RELEASE;
		String appVersion = ApplicationData.getInstance().getAppVerName();
		String userId = ApplicationData.getInstance().getUserId();
		String key = getKey();
		int commendId = ApplicationData.getInstance().getChannelNumber();
		String commendName = ApplicationData.getInstance().getChannelName();
		
		String sign = getRequestSign(uuid, platformCode, platformVersion, appVersion, jsonParam, userId, key);
		
		String params = "sign=" + sign;
		params += "&uuid=" + uuid;
		params += "&platformCode=" + platformCode;
		params += "&platformVersion=" + platformVersion;
		params += "&appVersion=" + appVersion;
		params += "&UserID=" + userId;
		params += "&action=" + action;
		params += "&params=" + jsonParam.replace("+", "%2B");
		params += "&cmdId=" + commendId;
		params += "&cmdName=" + commendName;
		
		return params;
	}
}
